import urllib2
import time
import settings
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = { 'User-Agent' : user_agent }

class tcols:
	yellow = '\033[93m'
	red = '\033[91m'
	none = '\033[0m'

def get(url):
	""" returns text on given url. If error returns None """
	req=urllib2.Request(url,None,headers)
	time.sleep(settings.waittime)
	if not settings.silent:
		print "Will get",url
		print "After waiting %1.2f seconds" % settings.waittime
	try:
		res=urllib2.urlopen(req)
	except urllib2.URLError, e:
		print tcols.red+"Error in getting %s :" % url ,tcols.none
		return None
	return unicode(res.read(),"utf-8")

if __name__=="__main__":
	print get("http://www.google.com.ua/")
